﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XModem.library
{
    public static class ParaList
    {
        /// <summary>
        /// 系统频率波特率
        /// </summary>
        private static List<ParaModel> sysParaList;
        /// <summary>
        /// 系统频率波特率
        /// </summary>
        public static List<ParaModel> SysParaList
        {
            get
            {
                if (null == sysParaList)
                {
                    sysParaList = new List<ParaModel>();

                    sysParaList.Add(new ParaModel() { PKey = "0xffff", PValue = "0xfef1" });
                    sysParaList.Add(new ParaModel() { PKey = "0xfff0", PValue = "0x36" });
                    sysParaList.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x20" });
                    sysParaList.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x00" });

                    sysParaList.Add(new ParaModel() { PKey = "0x004c", PValue = "0x00" });
                    sysParaList.Add(new ParaModel() { PKey = "0x004d", PValue = "0xdc" });
                    sysParaList.Add(new ParaModel() { PKey = "0x004e", PValue = "0x05" });
                    sysParaList.Add(new ParaModel() { PKey = "0x004f", PValue = "0x00" });


                    sysParaList.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    sysParaList.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x25" });
                    sysParaList.Add(new ParaModel() { PKey = "0x5042", PValue = "0x01" });
                    //by 20201010 此bug是由计算公式得来  当前不匹配 clk_baud_div = 晶振时钟/clk_buad = 27 000 000/ ( 115200 * 0x1a) = 108 = 0x09；
                    //sysParaList.Add(new ParaModel() { PKey = "0x500c", PValue = "0x09" });                  

                    //sysParaList.Add(new ParaModel() { PKey = "0x400b", PValue = "0x00" });
                    //sysParaList.Add(new ParaModel() { PKey = "0x4004", PValue = "0x74" });

                    sysParaList.Add(new ParaModel() { PKey = "0x500a", PValue = "0x00" });
                    sysParaList.Add(new ParaModel() { PKey = "0x5003", PValue = "0x74" });

                    sysParaList.Add(new ParaModel() { PKey = "0x500b", PValue = "0x00" });
                    sysParaList.Add(new ParaModel() { PKey = "0x5004", PValue = "0x74" });

                    sysParaList.Add(new ParaModel() { PKey = "0x5000", PValue = "0x78" });//enable uart

                    sysParaList.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    sysParaList.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x50" });
                    sysParaList.Add(new ParaModel() { PKey = "0x00bc", PValue = "0x21" });//uart1 initial
                    //sysParaList.Add(new ParaModel() { PKey = "0x0200", PValue = "0x00" });
                }
                return sysParaList;
            }

            set
            {
                sysParaList = value;
            }
        }
        /// <summary>
        /// 发送xmodel
        /// </summary>
        public static List<ParaModel> Tx_flash
        {
            get
            {
                if (null == tx_flash)
                {
                    tx_flash = new List<ParaModel>();

                    tx_flash.Add(new ParaModel() { PKey = "0xffff", PValue = "0xfef1" });
                    tx_flash.Add(new ParaModel() { PKey = "0xfff0", PValue = "0x36" });
                    tx_flash.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x20" });
                    tx_flash.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x00" });

                    tx_flash.Add(new ParaModel() { PKey = "0x1325", PValue = "0x01" });//Xmodem_Direction:0:receiver 1:transmit
					tx_flash.Add(new ParaModel() { PKey = "0x1324", PValue = "0x01" });//Xmodem_Mode_Type:0:xmodem 1:xmodem-1K
					tx_flash.Add(new ParaModel() { PKey = "0x132a", PValue = "0x00" });//Xmodem_TX_Data_Src_Type
                    tx_flash.Add(new ParaModel() { PKey = "0x132b", PValue = "0x00" });//Xmodem_TX_Data_Dest_Type
                    tx_flash.Add(new ParaModel() { PKey = "0x1334", PValue = "0x01" });//Xmodem_DMA_Enable

                    tx_flash.Add(new ParaModel() { PKey = "0x1330", PValue = "0x00" });//Xmodem_TX_Length
                    tx_flash.Add(new ParaModel() { PKey = "0x1331", PValue = "0x00" });
                    tx_flash.Add(new ParaModel() { PKey = "0x1332", PValue = "0x00" });
                    tx_flash.Add(new ParaModel() { PKey = "0x1333", PValue = "0x00" });

                    tx_flash.Add(new ParaModel() { PKey = "0x133f", PValue = "0x00" });//Xmodem_TX_Ack_Delay:delay的高位
                    tx_flash.Add(new ParaModel() { PKey = "0x133e", PValue = "0x0a" });//Xmodem_TX_Ack_Delay:delay的低位

                    tx_flash.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    tx_flash.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x50" });
                    tx_flash.Add(new ParaModel() { PKey = "0x0137", PValue = "0xc2" });//发送

                }
                return tx_flash;
            }

            set
            {
                tx_flash = value;
            }
        }
        /// <summary>
        /// 发送ikxmodel
        /// </summary>
        public static List<ParaModel> Tx_flash_1k
        {
            get
            {
                if (null == tx_flash_1k)
                {
                    tx_flash_1k = new List<ParaModel>();

                    tx_flash_1k.Add(new ParaModel() { PKey = "0xffff", PValue = "0xfef1" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0xfff0", PValue = "0x36" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x20" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x00" });

					tx_flash_1k.Add(new ParaModel() { PKey = "0x1325", PValue = "0x01" });//Xmodem_Direction:0:receiver 1:transmit
					tx_flash_1k.Add(new ParaModel() { PKey = "0x1324", PValue = "0x01" });//Xmodem_Mode_Type:0:xmodem 1:xmodem-1K
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x132a", PValue = "0x00" });//Xmodem_TX_Data_Src_Type
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x132b", PValue = "0x00" });//Xmodem_TX_Data_Dest_Type
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x1334", PValue = "0x01" });//Xmodem_DMA_Enable

                    tx_flash_1k.Add(new ParaModel() { PKey = "0x1330", PValue = "0x00" });//Xmodem_TX_Length
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x1331", PValue = "0x00" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x1332", PValue = "0x00" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x1333", PValue = "0x00" });

                    tx_flash_1k.Add(new ParaModel() { PKey = "0x133f", PValue = "0x00" });//Xmodem_TX_Ack_Delay:delay的高位
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x133e", PValue = "0x0a" });//Xmodem_TX_Ack_Delay:delay的低位

                    tx_flash_1k.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x50" });
                    tx_flash_1k.Add(new ParaModel() { PKey = "0x0137", PValue = "0xc2" });

                }
                return tx_flash_1k;
            }

            set
            {
                tx_flash_1k = value;
            }
        }
        /// <summary>
        /// 接收xmodel
        /// </summary>
        public static List<ParaModel> Rx_flash
        {
            get
            {
                if (null == rx_flash)
                {
                    rx_flash = new List<ParaModel>();
                    rx_flash.Add(new ParaModel() { PKey = "0xffff", PValue = "0xfef1" });
                    rx_flash.Add(new ParaModel() { PKey = "0xfff0", PValue = "0x36" });
                    rx_flash.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x20" });
                    rx_flash.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x00" });

					rx_flash.Add(new ParaModel() { PKey = "0x1325", PValue = "0x01" });//Xmodem_Direction: 0:receiver 1:transmit
					rx_flash.Add(new ParaModel() { PKey = "0x1324", PValue = "0x01" });//Xmodem_Mode_Type: 0:xmodem 1:xmodem-1K
                    rx_flash.Add(new ParaModel() { PKey = "0x1328", PValue = "0x00" });//Xmodem_RX_Data_Src_Type
                    rx_flash.Add(new ParaModel() { PKey = "0x1329", PValue = "0x00" });//Xmodem_RX_Data_Dest_Type
                    rx_flash.Add(new ParaModel() { PKey = "0x1334", PValue = "0x01" });//Xmodem_DMA_Enable

                    rx_flash.Add(new ParaModel() { PKey = "0x132c", PValue = "0x00" });//Xmodem_RX_Length
                    rx_flash.Add(new ParaModel() { PKey = "0x132d", PValue = "0x00" });
                    rx_flash.Add(new ParaModel() { PKey = "0x132e", PValue = "0x00" });
                    rx_flash.Add(new ParaModel() { PKey = "0x132f", PValue = "0x00" });

                    rx_flash.Add(new ParaModel() { PKey = "0x1341", PValue = "0x00" });//Xmodem_RX_Ack_Delay:delay的高位
                    rx_flash.Add(new ParaModel() { PKey = "0x1340", PValue = "0x24" });//Xmodem_RX_Ack_Delay:delay的低位

                    rx_flash.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    rx_flash.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x50" });
                    rx_flash.Add(new ParaModel() { PKey = "0x0137", PValue = "0xc1" });

                }
                return rx_flash;
            }

            set
            {
                rx_flash = value;
            }
        }
        /// <summary>
        /// 接受1kxmodel
        /// </summary>
        public static List<ParaModel> Rx_flash_1k
        {
            get
            {
                if (null == rx_flash_1k)
                {
                    rx_flash_1k = new List<ParaModel>();
                    rx_flash_1k.Add(new ParaModel() { PKey = "0xffff", PValue = "0xfef1" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0xfff0", PValue = "0x36" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x20" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x00" });

					rx_flash_1k.Add(new ParaModel() { PKey = "0x1325", PValue = "0x01" });//Xmodem_Direction:0:receiver 1:transmit
					rx_flash_1k.Add(new ParaModel() { PKey = "0x1324", PValue = "0x01" });//Xmodem_Mode_Type:0:xmodem 1:xmodem-1K
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x1328", PValue = "0x00" });//Xmodem_RX_Data_Src_Type
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x1329", PValue = "0x00" });//Xmodem_RX_Data_Dest_Type
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x1334", PValue = "0x01" });//Xmodem_DMA_Enable

                    rx_flash_1k.Add(new ParaModel() { PKey = "0x132c", PValue = "0x00" });//Xmodem_RX_Length
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x132d", PValue = "0x00" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x132e", PValue = "0x00" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x132f", PValue = "0x00" });

                    rx_flash_1k.Add(new ParaModel() { PKey = "0x1341", PValue = "0x00" });//Xmodem_RX_Ack_Delay:delay的高位
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x1340", PValue = "0x1a" });//Xmodem_RX_Ack_Delay:delay的低位

                    rx_flash_1k.Add(new ParaModel() { PKey = "0xfffd", PValue = "0x80" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0xfffe", PValue = "0x50" });
                    rx_flash_1k.Add(new ParaModel() { PKey = "0x0137", PValue = "0xc1" });

                }
                return rx_flash_1k;
            }

            set
            {
                rx_flash_1k = value;
            }
        }

        private static List<ParaModel> tx_flash;
        private static List<ParaModel> tx_flash_1k;


        private static List<ParaModel> rx_flash;
        private static List<ParaModel> rx_flash_1k;


    }


    public class ParaModel
    {
        public string PKey { get; set; }
        public string PValue { get; set; }

    }
}
